//
//  QuHuoListTableViewCell2.m
//  Experss
//
//  Created by wmwMAC on 17/8/11.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "QuHuoListTableViewCell2.h"


#import "DingDanTableCollectionViewCell.h"

@interface QuHuoListTableViewCell2()<UICollectionViewDelegate,UICollectionViewDataSource>
{
    UIViewController *currentVC;
}




@end

@implementation QuHuoListTableViewCell2

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.imageArray = [NSArray array];
        self.imageArray = @[@"",@"",@"",@"",@"",@""];
        [self createSubviews];
        
        currentVC = [BasePublicClass getCurrentVC];
    }
    return self;
}

- (void)createSubviews{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, kScreenWidth-110-15, 47)];
    label.text = @"订单编号 4398409903480983";
    label.textAlignment = NSTextAlignmentLeft;
    label.textColor = [UIColor blackColor];
    label.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:label];
    self.titleLabel = label;
    
    CGFloat xxx = kScreen_Width - 110;
    
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(xxx, 0, 70, 47)];
    label2.text = @"订单详情";
    label2.textAlignment = NSTextAlignmentCenter;
    label2.textColor = [UIColor blackColor];
    label2.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:label2];
    self.stateLabel = label2;
    
    UIImageView *rightImgView = [BasePublicCreatUI createImageViewFrame:CGRectMake(kScreenWidth-30, 15, 10, 17) imageName:@"fenlei_youjiantou" color:[UIColor whiteColor]];
    [self.contentView addSubview:rightImgView];
    
//    self.stateLabel.backgroundColor = [UIColor redColor];
//    self.titleLabel.backgroundColor = [UIColor yellowColor];
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.minimumInteritemSpacing = 7;
    layout.minimumLineSpacing = 7;
    layout.sectionInset = UIEdgeInsetsMake(26, 15, 6, 25);
    CGFloat width = (kScreen_Width - 40 - 30 - 40)/5.0;
    layout.itemSize = CGSizeMake(width, width);
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 47, kScreen_Width-40, width + 26+6 +0.01) collectionViewLayout:layout];
    collectionView.backgroundColor = [UIColor whiteColor];
    collectionView.showsVerticalScrollIndicator = NO;
    collectionView.showsHorizontalScrollIndicator = NO;
    collectionView.bounces = NO;
    collectionView.scrollEnabled = NO;
    [collectionView registerClass:[DingDanTableCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    collectionView.delegate = self;
    collectionView.dataSource = self;
    self.collectionView = collectionView;
    [self.contentView addSubview:collectionView];
    collectionView.userInteractionEnabled = NO;
    
    UIImageView *imgV = [BasePublicCreatUI createImageViewFrame:CGRectMake(kScreen_Width-40, 47 + 26 + (width-30)/2.0, 30, 30) imageName:@"tijiaodingdan_dian" color:[UIColor whiteColor]];
    imgV.contentMode = UIViewContentModeScaleAspectFit;
    self.moreImageView = imgV;
    [self.contentView addSubview:imgV];
    
    UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.collectionView.frame), SCREEN_WIDTH-30, 40)];
    label3.text = @"¥399.0 共7件，重量2.5kg";
    label3.textAlignment = NSTextAlignmentLeft;
    label3.textColor = [UIColor blackColor];
    label3.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:label3];
    
    self.priceLabel = label3;
    
    // 创建按钮
    CGFloat w = 90;
    CGFloat space = 15;
    CGFloat xbtx = SCREEN_WIDTH - w - space;
    CGFloat yy = CGRectGetMaxY(label3.frame) + 10;
    
    
    UIButton *btn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn.frame = CGRectMake(xbtx, yy, w, 35);
    btn.backgroundColor = [UIColor whiteColor];
    [btn setTitle:@"取货" forState:(UIControlStateNormal)];
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    [btn setTitleColor:RGBAColor(75, 170, 251, 1) forState:(UIControlStateNormal)];
    [btn addTarget:self action:@selector(quhuoBtnClicked) forControlEvents:(UIControlEventTouchUpInside)];
    btn.layer.cornerRadius = 35/2.0;
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = RGBAColor(75, 170, 251, 1).CGColor;
    btn.clipsToBounds = YES;
    [self.contentView addSubview:btn];
    
    self.rightBtn = btn;
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 47, SCREEN_WIDTH, 1)];
    lineView.backgroundColor = RGBAColor(240, 240, 240, 1);
    
    [self.contentView addSubview:lineView];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.priceLabel.frame), SCREEN_WIDTH, 1)];
    lineView2.backgroundColor = RGBAColor(240, 240, 240, 1);
    
    [self.contentView addSubview:lineView2];
    
    UIView *lineView3 = [[UIView alloc] initWithFrame:CGRectMake(0, (kScreen_Width - 40 - 30 - 40)/5.0 + 26+6 + 47 + 40 + 55, SCREEN_WIDTH, 10)];
    lineView3.backgroundColor = BaseColor;
    [self.contentView addSubview:lineView3];
    
}

- (void)quhuoBtnClicked{
    NSLog(@"quhuoBtnClicked");
}



- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.imageArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    DingDanTableCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.imgV.backgroundColor = [UIColor cyanColor];
    
    //    cell.imgV.image = self.imageArray[indexPath.item];
    
    //    [cell.imgV sd_setImageWithURL:[NSURL URLWithString:self.imageArray[indexPath.item]]];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
